home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: thads@csn.net (Thad Smith)
- Newsgroups: comp.lang.c,comp.lang.c.moderated
- Subject: Re: const pointer confusion...
- Date: 24 Mar 1996 11:41:47 -0600
- Organization: T3 Systems
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4j41gr$nje@solutions.solon.com>
- References: <4j06gm$7oa@solutions.solon.com>
- Reply-To: ThadSmith@acm.org
- NNTP-Posting-Host: solutions.solon.com
-
- In article <4j06gm$7oa@solutions.solon.com>,
- "Reed R. Mangino" <mangino@planet.net> wrote:
- >Could someone please straighten me out on this:
- >
- >1) const int *p = 10;
- > p is a constant pointer to an int, right? While p can be made to
- > point to something else, *p can never be assigned to, right?
- >
- >2) int *const p;
- > p is a pointer to an integer. *p can be assigned to, but p can
- > never be made to point to another address in memory, right?
- >
- >3) int const *p;
- > What the heck is this? I can't find anything like this in my
- > books, but my compiler thinks everything is hunky doory!???
-
- It is the same as
- const int *p;
- Standard C allows storage class specifiers (extern, static, register,
- etc.), type qualifiers (const, volatile), and type specifiers to be
- placed in any order, although placing storage class specifiers other
- than at the beginning is considered obsolescent. The location of
- "const" relative to asterisks is significant, but relative to type
- declaration is not.
-
- Thad
-